package com.tianji.learning.tasks;

import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
//@Component
public class DemoTaskJob {

    @XxlJob("demoJobHandler")
    public ReturnT<String> demoJobHandler() {
        XxlJobHelper.log("demoJobHandler");
        log.info("demoJobHandler:111");
        return ReturnT.SUCCESS;
    }
    @XxlJob("shardingJob")
    public ReturnT<String> shardingJobHandler() {
        int shardIndex = XxlJobHelper.getShardIndex();
        int shardTotal = XxlJobHelper.getShardTotal();
        XxlJobHelper.log("shardIndex:{},shardTotal:{}", shardIndex, shardTotal);
        return ReturnT.SUCCESS;
    }
}
